<?php
include "pwd_session.php";
function deldir($dir) {
	$dh=opendir($dir);
	while ($file=readdir($dh)) {
		if($file!="." && $file!="..") {
			$fullpath=$dir."/".$file;
			if(!is_dir($fullpath)) {
				unlink($fullpath);
			} else {
				deldir($fullpath);
			}
		}
	}
	closedir($dh);
	if(rmdir($dir)) {
		return true;
	} else {
		return false;
	}
}
$dir=$_POST['dir'] ? $_POST['dir'] : './';
if($_POST['create']=='create'){
	if($_POST['unlink']){
		$path=$dir.$_POST['unlink'];
		$re=unlink($path);
		if($re){
			echo "UnLink Success!";
		}else{
			echo "UnLink Error!";
		}
	}
	if($_POST['rmdir']){
		$re=deldir($_POST['rmdir']);
		if($re){
			echo "Deldir Success!";
		}else{
			echo "Deldir Error!";
		}
	}
}
?>
<form action="#" method="post" enctype="multipart/form-data">
	<input type="hidden" name="create" value="create" />
	Rmdir:<input type="text" name="rmdir" value="" /><br />
	UnLink:<input type="text" name="unlink" value="" /><br />
	Dir:<input type="text" name="dir" value="<?php echo $dir; ?>" />eq:./upfiles/
	<input type="submit" name="" value="Del" />
</form>
	</body>
</html>